Component({
  properties: {
    lyricData: {
      type: Array,
      value: []
    },
    currentTime: {
      type: Number,
      value: 0,
      observer: 'updateCurrentLyric'
    }
  },

  data: {
    currentLyricIndex: -1,
    scrollTop: 0
  },

  methods: {
    updateCurrentLyric(currentTime) {
      const lyricData = this.properties.lyricData;
      if (!lyricData || lyricData.length === 0) return;

      let index = -1;
      for (let i = 0; i < lyricData.length; i++) {
        if (currentTime >= lyricData[i].time) {
          index = i;
        } else {
          break;
        }
      }

      if (index !== this.data.currentLyricIndex) {
        this.setData({ currentLyricIndex: index });
        this.scrollToCurrentLyric(index);
      }
    },

    scrollToCurrentLyric(index) {
      if (index < 0) return;
      
      // 简化滚动实现：根据索引计算滚动位置
      const scrollTop = index * 60; // 每行歌词大约60rpx高度
      this.setData({ scrollTop });
    }
  }
});